﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_HisAbsence : System.Web.UI.Page
    {
        private IAbsenceBLL absenceBLL = new AbsenceBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["sta"] != null)
                    this.lblSta.Text = Request.QueryString["sta"].ToString();

                lblEmpSeq.Text = Session["emp_seq"].ToString();
                LoadDataGrid();
            }

        }
        public void LoadDataGrid()
        {
        //    IList<HisEducationInfo> Info = eduBLL.ListHisEducations(lblEmpSeq.Text);

            IList<AbsenceInfo> Info = absenceBLL.ListAbsences(lblEmpSeq.Text);
            RadGrid1.DataSource = Info;
            RadGrid1.DataBind();
        }

        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Sequence"]);

                absenceBLL.Delete(seq, 1);
            }
            LoadDataGrid();
        }

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridCommandItem)
            {
                GridCommandItem commandItem = e.Item as GridCommandItem;
                LinkButton button = commandItem.FindControl("cmdAddNew") as LinkButton;

                if (this.lblSta.Text == "v")
                {
                    button.Enabled = false;
                    button.Visible = true;
                    button.Text = "";
                }
            }
        }

        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (this.lblSta.Text == "v")
            {
                RadGrid1.Columns[0].Visible = false;
                RadGrid1.Columns[1].Visible = false;
            }
        }
    }
}
